<?php 
$page=1;
if(isset($_REQUEST['page'])){
	$page=$_REQUEST['page'];
}
$rowpage=10;
$pagestart=($page-1)*$rowpage;
$pageend=$pagestart+$rowpage;

$link='http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
if(isset($_SESSION['linkdealaccount']))
$link=$_SESSION['linkdealaccount'];
else
$_SESSION['linkdealaccount']=$link;
$numpage=ceil(count($list_deal_account)/$rowpage);

?>
<script type="text/javascript">
function goPage(link,on) {
		window.location.assign(link+"?page="+on)		
}

function enterTable(e,value){
    var key = window.event ? e.keyCode : e.which;
    if(key==13){
        if(value=="submit") submit();
        else{
    	document.getElementById(value).focus();
		document.getElementById(value).select();
		return false;
        } 
	}else
		return true;	
}

</script>
<div id="contents">
<div class="content_table_detail">
			<table cellspacing="0" cellpadding="0" border="0" style="border-collapse: collapse;margin-left: -10px;width: 980px;background: url('<?php echo base_url('admin/images/title_03.gif') ?>') repeat-x scroll 0% 0% transparent;" >
				<thead>
					<tr>
						<th style="text-align: left;background: url('<?php echo base_url('admin/images/title_03.gif') ?>') repeat-x scroll 0% 0% transparent;height: 24px;">Danh sách Deal</th>
						
					</tr>
				</thead>
				</table>
				<br>
		
			<table cellspacing="0" cellpadding="0" border="0" style="border-collapse: collapse;">
				<thead>
					<tr>
						<th style="width: 30px;">No.</th>
						<th style="width: 80px;">Danh mục</th>
						<th style="width: 150px;">Tên Deal</th>
						<th style="width: 70px;">Giá</th>
						<th style="width: 70px;">Giảm giá</th>
						<th style="width: 70px;">Giá khuyến mãi</th>
						<th style="width: 70px;">Trạng thái</th>
						<th style="width: 70px;"></th>
					</tr>
				</thead>
				<tbody>
				<?php 
				$vitri=0;
				foreach ($list_deal_account as $value ){
             		$vitri++;
					if($vitri>$pagestart && $vitri<=$pageend){
						
					?>
					<tr  style="cursor:pointer;">
						<td style="width: 30px;" ><?=$vitri?></td>
						
						
						<td><?=$value['nameVN']?></td>
						<td><?=$value['name']?></td>
						<td><?=number_format($value['price'])?></td>
						<td><?=$value['sale_off']?> %</td>
						<td><?=number_format($value['price_sale_off'])?></td>
						<td><?php if($value['status']==1) echo 'Đã phê duyệt'; if($value['status']==0) echo 'Chưa Phê Duyệt';?></td>
						<td>
						
						<div class="divBtn" style="width:60px; float:right; margin:0px 5px;" onclick="location.href='<?=base_url('account/edit_deal?did='.$value['id'])?>'" >Cập nhật</div>
						</td>
					</tr>
				<?php 
				
					}
					
				}
				
				
				
				?>						
				</tbody>
			</table>

			<div style="text-align:center; margin:10px 0px;">
				<div class="paginate_simple">
				<?php $pages=ceil($page/10)-1;
						if($pages>0){
							?>
							<a href="javascript:goPage('<?=$link?>',<?=($pages-1)*10+1?>)"><?=$l_prev?></a>
							<?php 		
						}
				?>
				
					<?php
					$co=0;
					 for($i=1;$i<=$numpage;$i++){
						$co++;
						if($i>$pages*10 && $i<=($pages+1)*10){
						if($page==$i){
						?>
						<strong><?=$i?></strong>
						<?php }else{?>
						<a href="javascript:goPage('<?=$link?>',<?=$i?>)"><?=$i?></a>
						<?php }
						}
						?>
						
						
					<?php }
					if($page<=($pages+1)*10 && $co >($pages+1)*10){
						
							?>
							<a href="javascript:goPage('<?=$link?>',<?=($pages+1)*10+1?>)"><?=$l_next?></a>
							<?php 		
						}
					?>
				</div>
			</div>

			</div>
			</div>